package com.example.administrator.szb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.szb.R;
import com.example.administrator.szb.bean.FaLvBean;

import java.util.List;

/**
 * Created by stone on 2018/1/19.
 */

public class FaLvadapter extends BaseAdapter {
    private Context context;
    private List list;
    LayoutInflater inflater;
    public FaLvadapter(Context context, List list) {
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public FaLvBean getItem(int position) {
        return (FaLvBean) list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null){
            convertView = inflater.inflate(R.layout.item_anli,null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.title.setSingleLine(false);
        FaLvBean faLvBean = getItem(position);
        holder.time2.setText("颁布时间："+faLvBean.getDate());
        holder.title.setText(faLvBean.getTitle());
        holder.content.setText(faLvBean.getMold());
        return convertView;
    }

    class ViewHolder{
        TextView time,time2,title,content;
        public ViewHolder(View view){
            title = view.findViewById(R.id.title);
            content = view.findViewById(R.id.content);
            time = view.findViewById(R.id.time);
            time2 = view.findViewById(R.id.time2);
            time2.setVisibility(View.VISIBLE);
        }
    }
}
